from core.basehandler import BaseHandler
from core.room import Room
from core.support import set_cutscene, get_game
from items.batteries import Batteries
from core.action import Action

class ComputerLab(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        # add inventory items
        self.add_item(Batteries())
        
        # build list of actions
        self.add_action(BookTeamRoom)
        self.add_action(Exit)
    
    # return description of room.
    def get_description(self):
        return "You are now in the Computer Lab."
    
    # return image of room
    def get_image(self):
        return 'ComputerLab.jpg'


class ComputerLabHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return ComputerLab

# define actions for this room

class Exit(Action):
    def __init__(self):
        Action.__init__(self, "Exit")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Back to the Hall"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'thirdfloorhallway'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

class BookTeamRoom(Action):
    def __init__(self):
        Action.__init__(self, "BookTeamRoom")    # do basic initialization for every action
    
    def get_description(self):
        return "Book a Team Room"
    
    def do_action(self,game,room,request):
        set_cutscene("Only room 230A was available... damned undergrad zombies!")
        game.get_player().add_status("room_booked")
        
    def is_enabled(self):
        return not get_game().get_player().has_status("room_booked")
        
        
    def get_method(self):
        return "post"
